#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <error.h>

typedef struct node
{
    int data;
    struct node * lchild;
    struct node * rchild;
}bitree_t;

//根节点从1开始
//n 表示一共的节点数
bitree_t * create_bitree(int i,int n)
{
    bitree_t * r = malloc(sizeof(bitree_t));
    r->data = i;
    printf("i=%d\n",i);

    if (2*i <= n)    //有左孩子
    {
        r->lchild = create_bitree(2*i,n);
    }
    else
    {
        r->lchild = NULL;   //左孩子为空
    }

    if (2*i+1 <= n)
    {
        r->rchild = create_bitree(2*i+1,n);
    }
    else
    {
        r->rchild = NULL;   //右孩子为空
    }
    
    return r;
}

int main(int argc, char const *argv[])
{
    bitree_t * R = create_bitree(1,15);
    return 0;
}
